<%@ page import="java.util.List" %>
<%@ page import="com.example.ordersystem.domain.Category" %>
<%@ page import="com.example.ordersystem.domain.Customer" %>
<%@ page import="com.example.ordersystem.domain.RoomAddress" %><%--
  Created by IntelliJ IDEA.
  User: 檬zhu
  Date: 2021/12/14
  Time: 15:32
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" %>
<html>
<head>
    <title>餐厅点餐系统</title>
    <link rel="icon" href="${pageContext.request.contextPath}/resources/images/index.jpg" type="image/x-icon"/>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/css/font.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/css/customer.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/js/jquery.js">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/js/jquery-1.9.1.min.js">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script src="${pageContext.request.contextPath}/resources/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/resources/js/xadmin.js"></script>
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=Lbn1SZBh2NknQy3nUgWl0aspF84KXQma"></script>
</head>
<body>
<%
    Customer customer = (Customer) session.getAttribute("customer");
    Object obj = session.getAttribute("merchantaddress");
    if (obj == null) {
%>
<script>
    layui.use('layer', function () {
        var layer = layui.layer;
    layer.alert('请选择门店',function () {
// window.location.href='http://localhost:8080/customer/optroomPage';
    layer.open({
        type: 2,
        title: '选择门店',
        area:['800px','600px'], //弹出层宽高
        content: '${pageContext.request.contextPath}/customer/optroomPage',
        end : function () {
            window.history.back(-1);
            location.reload();
        }
        });
    });
});
</script>
<%
    }else {
        String roomAddress = obj.toString();

%>
<!-- 顶部开始 -->
<div class="container">
    <div style="float: left">
        <img src="../resources/images/order.png" height="50px" width="100px">
    </div>
    <div class="logo"><a href="${pageContext.request.contextPath}/customer/optroomPage" style="font-family: FZShuTi;width: 300px; font-size: 30px; color: #FFFFFF">欢迎光临<%=roomAddress%>!</a></div>
    <ul class="layui-nav right" lay-filter="">
        <li class="layui-nav-item to-index" ><a href="#"  style="color: #FFFFFF" id="address">正在定位......</a></li>
        <li class="layui-nav-item">
            <a href="javascript:"  style="color: #FFFFFF"><%=customer.getName()%></a>
            <dl class="layui-nav-child"> <!-- 二级菜单 -->
                <dd><a onclick="x_admin_show('个人信息','http://localhost:8080/customer/personal',500,300)" style="color: #0099CC">个人信息</a></dd>
                <dd><a onclick="x_admin_show('修改密码','http://localhost:8080/customer/modifyPassPage')" style="color: #0099CC">修改密码</a></dd>
                <dd><a href="${pageContext.request.contextPath}/" style="color: #0099CC">退出</a></dd>
            </dl>
        </li>
        <li class="layui-nav-item to-index" ><a href="${pageContext.request.contextPath}/customer/homePage"  style="color: #FFFFFF">首页</a></li>
    </ul>

</div>
<!-- 顶部结束 -->
<!-- 中部开始 -->
<!-- 左侧菜单开始 -->
<div class="left-nav">
    <div id="side-nav">
        <ul id="nav">
            <li>
                <a href="javascript:">
                    <i class="iconfont">&#xe723;</i>
                    <cite>订单查看</cite>
                    <i class="iconfont nav_right">&#xe697;</i>
                </a>
                <ul class="sub-menu">
                    <li>
                        <a _href="/customer/ordersPage">
                            <i class="iconfont">&#xe6a7;</i>
                            <cite>我的订单</cite>
                        </a>
                    </li>
                </ul>
            </li>

            <li>
                <a href="javascript:">
                    <i class="iconfont">&#xe726;</i>
                    <cite>菜品查看</cite>
                    <i class="iconfont nav_right">&#xe697;</i>
                </a>
                <ul class="sub-menu">
                    <%
                        @SuppressWarnings("unchecked")
                        List<Category> categories = (List<Category>) request.getAttribute("categories");
                        for (Category category : categories) {
                    %>
                    <li>
                        <a _href="/customer/dish?categoryNum=<%=category.getNum()%>">
                            <i class="iconfont">&#xe756;</i>
                            <cite><%=category.getName()%></cite>
                        </a>
                    </li>
                    <%}%>

                </ul>
            </li>
            <li>
                <a href="javascript:">
                    <i class="iconfont">&#xe698;</i>
                    <cite>购物车</cite>
                    <i class="iconfont nav_right">&#xe697;</i>
                </a>
                <ul class="sub-menu">
                    <li>
                        <a _href="/customer/lineitems">
                            <i class="iconfont">&#xe6a7;</i>
                            <cite>我选的菜</cite>
                        </a>
                    </li>
                </ul>
            </li>
        </ul>
    </div>
</div>
<!-- <div class="x-slide_left"></div> -->
<!-- 左侧菜单结束 -->
<!-- 右侧主体开始 -->
<div class="page-content">
    <div class="layui-tab tab" lay-filter="xbs_tab" lay-allowclose="false">
        <ul class="layui-tab-title">
            <li>店铺评价</li>
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
                <iframe src='${pageContext.request.contextPath}/customer/commentsPage' frameborder="0" scrolling="yes" class="x-iframe"></iframe>
            </div>
        </div>
    </div>
</div>
<div class="page-content-bg"></div>
<!-- 右侧主体结束 -->
<!-- 中部结束 -->
<!-- 底部开始 -->
<center>
    <div class="footer">
        <div class="copyright">网上订餐系统─────Web开发技术课程设计</div>
    </div>
</center>
<%
    }
%>
<script type="text/javascript">

    var geolocation = new BMap.Geolocation();
    var gc = new BMap.Geocoder();
    var merchantLng;
    var merchantLat;

    geolocation.getCurrentPosition( function(r) {   //定位结果对象会传递给r变量

            if(this.getStatus() == BMAP_STATUS_SUCCESS)
            {  //通过Geolocation类的getStatus()可以判断是否成功定位。
                var pt = r.point;
                //alert('您的位置：'+r.point.lng+','+r.point.lat);
                merchantLng = r.point.lng;
                merchantLat = r.point.lat;
                //document.getElementById("address").innerHTML = merchantLat;
                gc.getLocation(pt, function(rs){
                    var addComp = rs.addressComponents;
                    //window.onload = function(){
                        document.getElementById("address").innerHTML = "你的位置："+addComp.province + addComp.city + addComp.district + addComp.street;
                    //}
                });
            }
            else
            {
                //关于状态码
                //BMAP_STATUS_SUCCESS   检索成功。对应数值“0”。
                //BMAP_STATUS_CITY_LIST 城市列表。对应数值“1”。
                //BMAP_STATUS_UNKNOWN_LOCATION  位置结果未知。对应数值“2”。
                //BMAP_STATUS_UNKNOWN_ROUTE 导航结果未知。对应数值“3”。
                //BMAP_STATUS_INVALID_KEY   非法密钥。对应数值“4”。
                //BMAP_STATUS_INVALID_REQUEST   非法请求。对应数值“5”。
                //BMAP_STATUS_PERMISSION_DENIED 没有权限。对应数值“6”。(自 1.1 新增)
                //BMAP_STATUS_SERVICE_UNAVAILABLE   服务不可用。对应数值“7”。(自 1.1 新增)
                //BMAP_STATUS_TIMEOUT   超时。对应数值“8”。(自 1.1 新增)
                switch( this.getStatus() )
                {
                    case 2:
                        alert( '位置结果未知 获取位置失败.' );
                        break;
                    case 3:
                        alert( '导航结果未知 获取位置失败..' );
                        break;
                    case 4:
                        alert( '非法密钥 获取位置失败.' );
                        break;
                    case 5:
                        alert( '对不起,非法请求位置  获取位置失败.' );
                        break;
                    case 6:
                        alert( '对不起,当前 没有权限 获取位置失败.' );
                        break;
                    case 7:
                        alert( '对不起,服务不可用 获取位置失败.' );
                        break;
                    case 8:
                        alert( '对不起,请求超时 获取位置失败.' );
                        break;

                }
            }

        },
        {enableHighAccuracy: true}
    )

</script>
</body>
</html>
